#include "stdafx.h"
#include "layer.h"
#include "hidden_layer.h"
#include "neuron.h"
#include "hidden_neuron.h"

namespace nnse
{
	extern io_module io_m;

	// Constructor and Destructor

	template <class T, class U> hidden_layer<T, U>::hidden_layer(MLP<T, U>^ p, unsigned int l_n)
	: layer<T, U>(p, l_n)
	{
		io_m.startup_stream << "Constructing hidden layer " << get_number() << std::endl;
		put_number_of_neurons(10);
		put_neurons();
	}

	template <class T, class U> hidden_layer<T, U>::~hidden_layer()
	{
		io_m.startup_stream << "Destructing hidden layer " << get_number() << std::endl;
	}

	// Accessor Functions

	template <class T, class U> void hidden_layer<T, U>::put_neurons()
	{
		neurons=gcnew array<hidden_neuron<T, U>^>(get_number_of_neurons());
		for (unsigned int n_n=0; n_n<get_number_of_neurons(); n_n++)
		{
			neurons[n_n]=gcnew hidden_neuron<T, U>(this, n_n);
		}
	}

	// Serialisation Functions

	template <class T, class U> void hidden_layer<T, U>::display(std::wofstream& out)
	{
		out << "Hidden Layer:" << std::endl;
		layer<T, U>::display(out);
	}

	// Explicit Instantiation

	template ref class hidden_layer<bool, double>;
	template ref class hidden_layer<unsigned char, double>;
}
